# Maintainer: Federico Amedeo Izzo <federico@izzo.pro>
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm/configs/gohan_defconfig

pkgname=linux-bq-gohan
pkgver=3.10.84
pkgrel=1
pkgdesc="BQ Aquaris X5 Plus kernel fork"
arch="armv7"
_carch="arm"
_flavor="bq-gohan"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="bash bc bison devicepkg-dev flex openssl-dev perl gcc4 linux-headers"

# Compiler: GCC 4 (doesn't boot when compiled with newer versions)
if [ "${CC:0:5}" != "gcc4-" ]; then
	CC="gcc4-$CC"
	HOSTCC="gcc4-gcc"
	CROSS_COMPILE="gcc4-$CROSS_COMPILE"
fi

# Source
_repository="android_kernel_bq_msm8976"
_commit="19147fab27a5104598d615c4ea939aee2e18ade8"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
	$_config
	gcc10-extern_YYLOC_global_declaration.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

build() {
	unset LDFLAGS
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"
}

sha512sums="4e9c7984e567482d7b550ee2bd737eca38355995935ea2653f6f9f605818813e3a3c0d9c4f3649c6897cf172b0009f020e8e3de129e6f64bf2874349b4ff8081  linux-bq-gohan-19147fab27a5104598d615c4ea939aee2e18ade8.tar.gz
d842833dc1de783f0d15b4622a3a50775714ec8dc331220c8fa6764c30ea02ad8f97361c65b40dca25f9aeb3e717c3be44bef40176fb46a1d8812bfff369865f  config-bq-gohan.armv7
2b48f1bf0e3f70703d2cdafc47d5e615cc7c56c70bec56b2e3297d3fa4a7a1321d649a8679614553dde8fe52ff1051dae38d5990e3744c9ca986d92187dcdbeb  gcc10-extern_YYLOC_global_declaration.patch"
